package com.atguigu.gmall.pay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.atguigu.gmall.common.annotation.EnableUserHeaderInterceptor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2024/10/14 4:43
 */
@EnableFeignClients(basePackages = {"com.atguigu.gmall.feign.order"})
@EnableUserHeaderInterceptor
@EnableConfigurationProperties(AlipayProperties.class)
@Configuration
public class AlipayConfig {
    @Bean
    public AlipayClient alipayClient( AlipayProperties properties){
        return new DefaultAlipayClient(properties.getGatewayUrl(),
                properties.getApp_id(),
                properties.getMerchant_private_key(),
                "json",
                properties.getCharset(),
                properties.getAlipay_public_key(), properties.getSign_type());
    }
}
